﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
using TradeManage;
using Users_Management;
using WindowsFormsApp3;

namespace LoginTest
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            LoginFrm.department = LoginFrm.GetDepartmentFromDatabase(LoginFrm.userID);
            GXFactoryDBEntities dbEntities = new GXFactoryDBEntities();
            this.Text = "宁德国信工厂" + "管理系统-" + LoginFrm.selectFacotoryname;
            this.statusUser.Text = "当前用户：" + LoginFrm.userID + "(" + LoginFrm.roleName + ")" + "-" + LoginFrm.department;
            System.Timers.Timer timer = new System.Timers.Timer(1000);
            timer.Elapsed += new System.Timers.ElapsedEventHandler(refreshTime);
            timer.AutoReset = true;
            timer.Enabled = true;


            if (!LoginFrm.roleName.Contains("管理员"))
            {
                menuSysUser.Visible = false;
            }

            if (LoginFrm.roleName == "仓管员")
            {
                menuBaseManage.Visible = false;
                inforseach.Visible = false;
                menuSysManage.Visible = false;
                progressTool.Visible = false;
                SizeCossTool.Visible = false;
                ParkegeTool.Visible = false;
                ToolStrip.Visible = false;

                if (LoginFrm.roleName == "成品仓库")
                {
                    parterTool.Visible = false;
                }
                else
                {
                    outstockTool.Visible = false;
                }
            }

            if(LoginFrm.roleName == "运输员")
            {
                menuBaseManage.Visible= false;
                inforseach.Visible= false;
                menuSysManage.Visible = false;
                progressTool.Visible = false;
                SizeCossTool.Visible = false;
                ParkegeTool.Visible = false;
                parterTool.Visible = false;
                ToolStrip.Visible= false;
            }

            if(LoginFrm.roleName == "质检员")
            {
                menuBaseManage.Visible = false;
                inforseach.Visible = false;
                menuSysManage.Visible = false;
                progressTool.Visible = false;
                SizeCossTool.Visible = false;
            }  

            if(LoginFrm.roleName == "客户跟单员")
            {
                menuBaseManage.Visible = false;
                OrderRoomTool.Visible = false;
            }

            if(LoginFrm.roleName == "工厂跟单员")
            {

            }
        }

        private void refreshTime(object sender, ElapsedEventArgs e)
        {
            this.statusNull.Text = "当前时间：" + DateTime.Now.ToString();
        }

        private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new AboutBox1().Show();
        }

        private void OrderRoomTool_Click(object sender, EventArgs e)
        {
            new ClientOrder().Show(); 
        }

        private void menuBaseManage_Click(object sender, EventArgs e)
        {
            new BaseManage().Show();
        }

        private void inforseach_Click(object sender, EventArgs e)
        {
            new Inforseach().Show();
        }

        private void ToolStrip_Click(object sender, EventArgs e)
        {
            new ToolStrip().Show();
        }

        private void menuSysUser_Click(object sender, EventArgs e)
        {
            new UsersManagement().Show();
        }

        private void menuSysManage_Click(object sender, EventArgs e)
        {
            new UsersManagement().Show();
        }

        private void 跟单管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //new FinishedproductInOut().Show();
            //运行FinishedproductInOut_Load函数
            FinishedproductInOut finishedproductInOut = new FinishedproductInOut();
            finishedproductInOut.Show();
        }
    }
}
